package com.nwpu.bigdata.util.impl;

import org.influxdb.InfluxDB;


import org.influxdb.InfluxDBFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;

import com.nwpu.bigdata.util.InfluxDBUtil;


/**
 * @author chengar zhanggr
 * 
 */
@Configuration
@ImportResource(locations= {"classpath:/xmlConfig/spring/applicationContext-util.xml"})
public class InfluxDBUtilImpl implements InfluxDBUtil {

	@Value("${influxdb.user}")
	private String userName;
	
	@Value("${influxdb.password}")
	private String password;
	
	@Value("${influxdb.url}")
	private String url;
	
	@Override
	@Bean("influxDB")
	public InfluxDB builder() {
			synchronized (this) {
					return  InfluxDBFactory.connect(url, userName, password);
			}
	}

}
